home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * This file handles all of the pop-up menu options. It updates the
- * menu when needed, and decides what parts were clicked on.
- **********************************************************************/
-
- #include "Creator Changer.h"
- #include "Creator Changer.menu.h"
-
-
- /**********************************************************************
- * Function Handle_pop_up_menu(), this function handles the events
- * given to the prefered types pop-up menu.
- **********************************************************************/
-
- void Handle_pt_Pop_Up_Menu(Handle menu_handle, DialogPtr the_dialog, int creator, int file, int description)
- {
-
- Str32 description_type;
- Str4 creator_type, file_type;
- short item_type, the_choice;
- Handle creator_handle, file_handle, desc_handle;
- pref_types **rsrc_handle;
- Rect creator_rect, file_rect;
-
- the_choice=GetCtlValue((ControlHandle)menu_handle);
- if(the_choice)
- {
- UseResFile(CreatorChangerPref);
- rsrc_handle=(pref_types **)GetResource(PREF_PT, The_pt_Type[the_choice]);
- if(description) p_Str_Copy((**rsrc_handle).Description, description_type);
- p_Str_Copy((**rsrc_handle).CreatorType, creator_type);
- p_Str_Copy((**rsrc_handle).FileType, file_type);
- UseResFile(CreatorChangerApp);
-
- if(description)
- {
- GetDItem(the_dialog, description, &item_type, &desc_handle, &file_rect);
- SetIText(desc_handle, description_type);
- }
-
- GetDItem(the_dialog, creator, &item_type, &creator_handle, &creator_rect);
- SetIText(creator_handle, creator_type);
-
- GetDItem(the_dialog, file, &item_type, &file_handle, &file_rect);
- SetIText(file_handle, file_type);
- ReleaseResource((Handle)rsrc_handle);
- }
- (**(ControlHandle)menu_handle).contrlValue=0;
- if(!description) Draw1Control((ControlHandle)menu_handle);
- PT_Item_To_Edit=the_choice;
-
- }
-
-
-
- /**********************************************************************
- * Function Make_Pop_Up_Menu(), this function makes the pop-up menu
- * for the prefered types menu.
- **********************************************************************/
-
- void Make_Pop_Up_Menu(short ID, OSType the_type, short num)
- {
-
- short item;
- pref_types **rsrc_handle_pt;
- auto_chng **rsrc_handle_ac;
- MenuHandle menu_handle;
-
- menu_handle=GetMenu(ID);
- DisposeMenu(menu_handle);
-
- menu_handle=GetMenu(ID);
- UseResFile(CreatorChangerPref);
- for(item=0;item<num;item++)
- {
- if(the_type==PREF_PT)
- {
- The_pt_Type[item+1]=item+Strt_Rsrc;
- rsrc_handle_pt=(pref_types **)GetResource(the_type, item+128);
- InsMenuItem(menu_handle, (**rsrc_handle_pt).Description, item);
- ReleaseResource((Handle)rsrc_handle_pt);
- }
- else if(the_type==PREF_AC)
- {
- The_ac_Type[item+1]=item+Strt_Rsrc;
- rsrc_handle_ac=(auto_chng **)GetResource(PREF_AC, item+128);
- InsMenuItem(menu_handle, (**rsrc_handle_ac).Name, item);
- ReleaseResource((Handle)rsrc_handle_ac);
- }
- }
- UseResFile(CreatorChangerApp);
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_ac_Pop_Up_Menu(), this function handles the events
- * given to the auto change pop-up menu.
- **********************************************************************/
-
- void Handle_ac_Pop_Up_Menu(Handle menu_handle, DialogPtr the_dialog, int from_file_id, int to_creator_id, int to_file_id)
- {
-
- Str16 name;
- Str4 from_file, to_creator, to_file;
- short the_type, the_choice;
- Handle the_handle;
- Rect the_rect;
- auto_chng **rsrc_handle;
-
- the_choice=GetCtlValue((ControlHandle)menu_handle);
- if(the_choice)
- {
- UseResFile(CreatorChangerPref);
- rsrc_handle=(auto_chng **)GetResource(PREF_AC, The_ac_Type[the_choice]);
-
- p_Str_Copy((**rsrc_handle).FromFile, from_file);
- p_Str_Copy((**rsrc_handle).ToCreator, to_creator);
- p_Str_Copy((**rsrc_handle).ToFile, to_file);
- UseResFile(CreatorChangerApp);
-
- GetDItem(the_dialog, from_file_id, &the_type, &the_handle, &the_rect);
- SetIText(the_handle, from_file);
-
- GetDItem(the_dialog, to_creator_id, &the_type, &the_handle, &the_rect);
- SetIText(the_handle, to_creator);
-
- GetDItem(the_dialog, to_file_id, &the_type, &the_handle, &the_rect);
- SetIText(the_handle, to_file);
-
- ReleaseResource((Handle)rsrc_handle);
- }
- (**(ControlHandle)menu_handle).contrlValue=0;
- Draw1Control((ControlHandle)menu_handle);
- AC_Item_To_Edit=the_choice;
-
- }